package cn.example.vip.mall.seckill.controller;

import cn.example.vip.mall.seckill.service.SeckillOrderService;
import cn.example.vip.mall.util.RespResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 抢单功能
 */
@CrossOrigin
@RestController
@RequestMapping(value = "/seckill/order")
public class SeckillOrderController {

    @Autowired
    private SeckillOrderService seckillOrderService;
    
    /**
     * 非热门商品抢单操作，由拦截器逻辑进行执行
     * @param requestMap :username,id,num
     * @return
     */
    @PostMapping
    public RespResult addOrder(@RequestParam(required = false) Map<String, Object> requestMap){
        seckillOrderService.addOrder(requestMap);
        return RespResult.ok("抢单成功");
    }

}
